package org.lex.swing;

import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.text.JTextComponent;

public class SelectAllWhenGainFocus extends FocusAdapter {
	private static FocusListener instance = new SelectAllWhenGainFocus();

	public SelectAllWhenGainFocus() {
		super();
	}

	public void focusGained(FocusEvent e) {
		((JTextComponent) e.getComponent()).selectAll();
	}

	public static FocusListener getInstance() {
		return instance;
	}
}
